<?php
/*
 * [JINYUN!] (C)2001-2099 Jinyunweb.com
 * This is NOT a freeware, use is subject to license terms
 * $Id: 2017-12-13 03:39:35 apple $
*/
/*
	选择卡券modal，通过访问此页面选择获取指定卡券id
*/
defined('BY_JYA') or exit('error');
$_RQ['op']=$_RQ['op']?$_RQ['op']:'list';
$merchid=$_RQ['merchid']?:$this->checklogin();
$return=array();
	//会员列表
	$pindex = max(1, intval($_RQ['page']));
	$psize = 10;
	$return['params']=$params=array();
	$params=array('uniacid'=>$_SESSION['uniacid']);
	$params['merchid']=$merchid;
	$fields=array('id','name','nickname','mobile');
	if($_RQ['find']){
		$field=in_array($_RQ['field'],$fields)?$_RQ['field']:'nickname';
		$params2=array('uniacid'=>$_SESSION['uniacid']);
		$params2[$field.' like']='%'.$_RQ['find'].'%';
		$mids=pdo_getall('core_members',$params2,array('id','nickname'),'id');
		if($mids){
			$mids=array_keys($mids);
		}else{
			$mids=-1;
		}
		$params['mid']=$mids;
		$return['params']['find']=$_RQ['find'];
		$return['params']['field']=$field;
	}
	$list=pdo_getslice('jy_merch_member',$params,array($pindex,$psize),$total,array('mid','name','mobile','credit2'),'','id desc');
	foreach($list as $k=>&$item){
			$item['member']=cfc('core')->member_show($item['mid']);	
			$item['name']=$item['name']?:$item['member']['nickname'];
			$item['avatar']=$item['member']['avatar'];
			if($_RQ['op']=='many'){
				$item['res']=array(
					'mid'=>$item['mid'],
					'credit2'=>$item['credit2'],
					'title'=>$item['name'],
					'image'=>$item['avatar']
				);
			}else{
				$item['res']=$item['mid'];
			}
	}
	$return['list']=$list;
	$totalpage=ceil($total/$psize);
	$totalpage=intval($totalpage);
	$return['totalpage'] =$totalpage;
	$return['params']['page'] =$pindex;
	$return['htmls']=array(
		'type'=>'list',
		'tabs'=>array(
			//array('op'=>'list','title'=>'会员列表'),
		),
		'list'=>array('data'=>'list','tip'=>'[温馨提示]：为保障客户资料隐私，只允许搜索显示！','del_one'=>false,'delall'=>false,'edit'=>false,'list'=>array(
		    array('name'=>'mid','title'=>'会员id','type'=>'string'),
			array('name'=>'member','title'=>'会员信息','type'=>'member'),
			array('name'=>'name','title'=>'姓名','type'=>'string'),
			array('name'=>'nickname','title'=>'昵称','type'=>'string'),
			array('name'=>'mobile','title'=>'电话','type'=>'string'),
		),'action'=>array(
			array('type'=>'modal_result','name'=>'res','title_field'=>'nickname','title'=>'选取'),
		)),
		'search_one'=>array('name'=>'find','select_name'=>'field','select_title'=>'筛选','is_radio'=>true,'options'=>'fields'),
	);
	$return['fields']=array(
		'id'=>'MID',
		'name'=>'姓名',
		'nickname'=>'昵称',
		'mobile'=>'会员手机',
	);
	exi($return);

?>